package cn.seaboot.admin.flake.web;

import cn.seaboot.admin.flake.bean.FlakeParamMapping;
import cn.seaboot.admin.flake.service.FlakeParamMappingService;
import cn.seaboot.admin.mvc.argument.Params;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 参数字段映射 [T_FLAKE_PARAM_MAPPING] Controller
 *
 * @author Mr.css on 2018-6-20
 */
@Controller
@Tag(name = "参数字段映射 [T_FLAKE_PARAM_MAPPING] 管理")
@RequestMapping("flakeParamMapping")
public class FlakeParamMappingCtrl {

    @Resource
    private FlakeParamMappingService flakeParamMappingService;

    /**
     * 参数字段映射 - 增
     *
     * @param pojo pojo
     * @return affected rows
     */
    @ResponseBody
    @Operation(description = "参数字段映射 [T_FLAKE_PARAM_MAPPING] 增")
    @RequestMapping(value = "info", method = RequestMethod.POST)
    public int saveInfo(@Validated FlakeParamMapping pojo) {
        return flakeParamMappingService.insert(pojo);
    }

    /**
     * 参数字段映射 - 删
     *
     * @param id id
     * @return affected rows
     */
    @ResponseBody
    @Operation(description = "参数字段映射 [T_FLAKE_PARAM_MAPPING] 删")
    @RequestMapping(value = "info", method = RequestMethod.DELETE)
    public int deleteInfo(@Params String id) {
        return flakeParamMappingService.deleteById(id);
    }

    /**
     * 参数字段映射 - 查
     *
     * @param id id
     * @return pojo
     */
    @ResponseBody
    @Operation(description = "参数字段映射 [T_FLAKE_PARAM_MAPPING] 查")
    @RequestMapping(value = "info", method = RequestMethod.GET)
    public FlakeParamMapping queryById(@Params String id) {
        return flakeParamMappingService.queryById(id);
    }

    /**
     * 参数字段映射 - 改
     *
     * @param pojo pojo
     * @return affected rows
     */
    @ResponseBody
    @Operation(description = "参数字段映射 [T_FLAKE_PARAM_MAPPING] 改")
    @RequestMapping(value = "info", method = RequestMethod.PUT)
    public int updateInfo(@Validated FlakeParamMapping pojo) {
        return flakeParamMappingService.updateById(pojo);
    }

//    /**
//     * 参数字段映射 - 查列表
//     *
//     * @param params 参数
//     * @return PageInfo
//     */
//    @Operation(description = "参数字段映射 [T_FLAKE_PARAM_MAPPING] 列表查询")
//    @Parameters({@Parameter(name = "page", description = "页号"),
//            @Parameter(name = "limit", description = "行数"),
//            @Parameter(name = "sort", description = "排序")})
//    @ResponseBody
//    @RequestMapping(value = "page", method = RequestMethod.GET)
//    public PageInfo<FlakeParamMapping> queryList(@RequestParam Map<String, Object> params, @RequestParam String id) {
//        return Pagination.of(id, e -> flakeParamMappingService.queryList(id));
//    }
}
